package com.justgame.project.cloud.common.query;

import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@SuppressWarnings("all")
@Getter
public class BaseSelectBuilder {
    private final List<Query> queries;

    protected BaseSelectBuilder(List<Query> queries) {
        this.queries = queries;
    }

    protected <T extends BaseSelectBuilder> T add(Query query){
        queries.add(query);
        return (T)this;
    }

    protected <T extends BaseSelectBuilder,Other extends BaseSelectBuilder> T add(Other selectBuilder){
        queries.addAll(selectBuilder.getQueries());
        return (T)this;
    }

    protected <T extends BaseSelectBuilder> T addAll(List<Query> queries){
        this.queries.addAll(queries);
        return (T)this;
    }

    protected <T extends BaseSelectBuilder> T addAll(Query[] queries){
        this.queries.addAll(Arrays.asList(queries));
        return (T)this;
    }

    protected BaseSelectBuilder() {
        queries = new LinkedList<>();
    }
}
